package com.gcsoftware.gateway.GWImpl.basics;

import com.gcsoftware.gateway.GWImpl.xml.xmlDataProtection;
import com.gcsoftware.gateway.GWImpl.xml.xmlDataProtectionWithSax;
import com.gcsoftware.gateway.utils.enTextContentType;

import java.util.Map;

/**
 * Created by yinpeng on 18/1/23.
 */
public class gatewayMasker
{
    dataProtection dProt = null;
    private Map<String ,Object> argsMap;
    public void initialMaskerRule()
    {

    }
    public gatewayMasker() {}
    public gatewayMasker( Map<String ,Object> argsMap) {
        this.argsMap = argsMap;
    }

    public String execute(String originalText, enTextContentType ContentType , String charSet)
    {
        switch(ContentType)
        {
            case JSON:
            {
                break;
            }
            case XML:
            {
                dProt = new xmlDataProtectionWithSax();
                break;
            }
            case JAVASCRIPT:
            {
                break;
            }
            case TEXT:
            {
                break;
            }
            case UNKNOW:
            {
                break;
            }
            default:
            {
                break;
            }
        }
        String maskerText;
        if(null != dProt)
        {
            dProt.setArgMap(argsMap);
            maskerText  = dProt.protectExecute(originalText,charSet);
        }
        else
        {
            maskerText = originalText;
        }
        return maskerText;
    }
}
